package com.liangzhong.modules.PlayerCenter.command
{
	import com.liangzhong.constants.NotificationConstants;
	import com.liangzhong.model.type.BuildingType;
	import com.liangzhong.proxy.PlayerCenter.PlayerCenterProxy;
	import com.liangzhong.proxyconstant.PlayerCenter.PlayerCenterConstant;
	
	import lz.controls.Alert;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	/**
	 *球员 中心 
	 * @author Administrator
	 * 
	 */	
	public class PlayerCenterCommand extends SimpleCommand
	{
		public function PlayerCenterCommand()
		{
			super();
		}
		override public function execute(notification:INotification):void
		{
			var proxy:PlayerCenterProxy
			switch(notification.getName())
			{
				case PlayerCenterConstant.PLAYERCENTER_MEDIATOR_NOTIFICATION:
					meditortocommand(notification);
					break;
				case NotificationConstants.COMMON_DROP_TIME://返回清除球员中心冷却时间
					if(notification.getBody() == BuildingType.PLAYERCENTER)
					{
						proxy = facade.retrieveProxy(PlayerCenterProxy.PROXYNAME) as PlayerCenterProxy;
						proxy.getClearUpTime(notification.getBody());
						Alert.showErrorTip("冷却成功");
					}
					
					
					break;
				case NotificationConstants.ADD_PLAYER://获得球员
					proxy = facade.retrieveProxy(PlayerCenterProxy.PROXYNAME) as PlayerCenterProxy;
					proxy.addPlayer(notification.getBody());
					break;
			}
		}
		/**
		 * mediator 到 command处理
		 * @param no
		 * 
		 */
		private function meditortocommand(notification:INotification):void
		{
			var proxy:PlayerCenterProxy = facade.retrieveProxy(PlayerCenterProxy.PROXYNAME) as PlayerCenterProxy;
			switch(notification.getType())
			{
				case PlayerCenterConstant.PLAYERCENTER_UPGRADE://请求球员中心升级
					proxy.requestUpGrade(notification.getBody());
					break;
				case PlayerCenterConstant.CLEAR_UP_TIME://请求清除冷却时间
					proxy.requestClearUpTime(notification.getBody());
					break;
				case PlayerCenterConstant.REPLY_BUFF://回复buff
					proxy.requestReplyBuff(notification.getBody());
					break;
				case PlayerCenterConstant.REPLY_POWER://回复体力
					proxy.requestReplyPower(notification.getBody());
					break;
				case PlayerCenterConstant.ADD_MORMAL:
					proxy.requestAddMoral(notification.getBody());
					break;
				case PlayerCenterConstant.REMOVE_PLAYER:
					proxy.requestRemovePlayer(notification.getBody());
					break;
				case PlayerCenterConstant.ADD_PLAYER_CELL://增加球员格子
					proxy.requestaddPlayerCell();
					break;
				case PlayerCenterConstant.SAVE_BATTLEARRAY:
					proxy.requestsave_battlearray(notification.getBody());
					break;
				case PlayerCenterConstant.REPLACE_EQUIP:
					proxy.replace_equip(notification.getBody());
					break;
				case PlayerCenterConstant.CHANGE_PLAYER_NUMBER://改变球员号码 
					proxy.requestChangePlayerNumber(notification.getBody());
					break;
				case PlayerCenterConstant.UPDATE_PLAYER_POWER://更新球员体力
					proxy.requestPlayerPower(notification.getBody());
					break;
				
			}
		}
	}
}